#include <stdlib.h>
#include <math.h>
#include "Object.h"

Object::Object(Vertex * corner1, Vertex * corner2)
{

	this->vertices = new VertexList(corner1);
	this->vertices->Add(corner2);
}
Object::~Object()
{

}
void Object::Draw()
{
	if(vertices)
		vertices->Draw();
	
	//draw a box using the two corners
}

void Object::CheckHover(Mouse * mouse)
{
	if(vertices)
		vertices->HoverCheck(mouse);
}	
Vertex * Object::GetHover(Mouse * mouse)
{
	if(vertices)
		return vertices->GetHoverVertex(mouse);
	return NULL;	
}
char * Object::GetTag()
{
	if(vertices && vertices->head && vertices->head->next)
	{
		Vertex * corner2 = vertices->head->payload;
		Vertex * corner1 = vertices->head->next->payload;
		
		char * tag = (char*)malloc(sizeof(char)*(80));
		sprintf(tag,"<boundingbox, (%.3f,%.3f), (%.3f,%.3f), (%.3f,%.3f), (%.3f,%.3f)>",
			corner1->GetPosition().x,corner1->GetPosition().y,
			corner2->GetPosition().x,corner1->GetPosition().y,
			corner2->GetPosition().x,corner2->GetPosition().y,
			corner1->GetPosition().x,corner2->GetPosition().y);
		return tag;
	}

	return NULL;
}
VertexList * Object::GetVertices()
{
	return vertices;
}
